import { useThemeChange } from '@/hooks';
import { useEffect, useState } from 'react';
import { EchartsComp } from './echarts';
import { DeductionIncome, DeductionPrice, DeviationTariff } from './helper';
// 偏差分析
export function ChartDealTariff({
  data = {},
  scale = 1,
  isFullScreenEcharts = false,
  getRef = () => {},
}) {
  const [config, setConfig] = useState();
  const { theme } = useThemeChange();

  useEffect(() => {
    setTimeout(() => {
      setConfig({ ...DeviationTariff(data, scale) });
    }, 1);
  }, [data, theme, isFullScreenEcharts]);

  return <EchartsComp config={config} getRef={getRef} />;
}
// 电费分析
export function ChartDealIncome({
  data = {},
  scale = 1,
  isFullScreenEcharts = false,
  getRef = () => {},
}) {
  const [config, setConfig] = useState();
  const { theme } = useThemeChange();
  useEffect(() => {
    setTimeout(() => {
      setConfig({ ...DeductionIncome(data, scale) });
    }, 1);
  }, [data, theme, isFullScreenEcharts]);
  return <EchartsComp config={config} getRef={getRef} />;
}
// 电价分析
export function ChartDealPrice({
  data = {},
  scale = 1,
  isFullScreenEcharts = false,
  getRef = () => {},
}) {
  const [config, setConfig] = useState();
  const { theme } = useThemeChange();
  useEffect(() => {
    setTimeout(() => {
      setConfig({ ...DeductionPrice(data, scale) });
    }, 1);
  }, [data, theme, isFullScreenEcharts]);
  return <EchartsComp config={config} getRef={getRef} />;
}
